<div class="modal-dialog " id="metaGenAttr_A_Dialog">
  <div class="modal-content">
    <div class="modal-header modal-header-condensed">
      <button type="button" class="close" data-dismiss="modal" aria-label="Close">
        <span aria-hidden="true">×</span></button>
      <h4 class="modal-title"><i class="fa fa-plus"></i>新增元属性</h4>
    </div>
    <div class="modal-body" >
      <form class="form-horizontal" id="add_form_metaGenAttr" role="form"  >
        <input type="hidden" name="objId" id="objId" value="${objId}" >
        <div class="form-group">
          <span class=" col-xs-2 control-label"> 名称</span>
          <div class=" col-xs-4">
            <input type="text" class="form-control" placeholder="属性的英文类名" name="attrName" id="attrName" >
          </div>
          <span class=" col-xs-2 control-label"> 备注</span>
          <div class=" col-xs-4 ">
            <input type="text" class="form-control" placeholder="属性的中文类名" name="attrComment" id="attrComment">
          </div>
        </div>
        <div class="form-group">
          <span class=" col-xs-2 control-label"> 对应关系</span>
          <div class=" col-xs-4">
            <input type="text" class="form-control" placeholder="对象与属性的对应关系" name="relationShip" id="relationShip" >
          </div>
          <span class=" col-xs-2 control-label"> 映射类型</span>
          <div class=" col-xs-4">
            <input type="text" class="form-control" placeholder="属性的集合类型" name="relationType" id="relationType" >
          </div>
        </div>
        <div class="form-group">
          <span class=" col-xs-2 control-label"> 完整类型</span>
          <div class="col-xs-4">
            <input type="text" class="form-control" placeholder="对象的完整类型" name="attrType" id="attrType" >
          </div>
          <span class=" col-xs-2 control-label"> 类型</span>
          <div class=" col-xs-4">
            <input type="text" class="form-control" placeholder="对象的类型简写" name="attrShortTypeName" id="attrShortTypeName" >
          </div>
        </div>
      </form>
    </div>
    <div class="modal-footer modal-footer-condensed ">
      <button type="button" class="btn btn-default" data-dismiss="modal" >关闭</button>
      <button type="button" class="btn btn-primary" id="metaGenAttr_A_Btn">确认</button>
    </div>
  </div>
</div>
<script type="text/javascript">
  require([ "jquery","framework","validate"],function($) {
    var $container = $("#metaGenAttr_A_Dialog");
    var $parentContainer  = $container.parent();
    var reftableid = $parentContainer.data('reftableid');
    ${generateValidateJS("#add_form_metaGenAttr","frameworkOptions.showValidateMessages","com.maker.generator.entity.MetaGenAttr","")};

    function validateAddFrom(){ 
        var addFromData = new Object();
        var metaObj = new Object();
        metaObj.id = $container.find('#objId').val();
        addFromData.metaObj = metaObj;
        addFromData.attrType =         $container.find('#attrType').val();
        addFromData.attrShortTypeName =      $container.find('#attrShortTypeName').val();
        addFromData.relationType =  $container.find('#relationType').val();
        addFromData.relationShip =     $container.find('#relationShip').val();
        addFromData.attrComment =     $container.find('#attrComment').val();
        addFromData.attrName =     $container.find('#attrName').val();
        if(!$container.find("#add_form_metaGenAttr").valid()) {
            addFromData.validated = false;
        }else{
            addFromData.validated = true;
        }
        
        return addFromData;
    };
  
    
    $container.find('#metaGenAttr_A_Btn').on('click',function(e){
        var postData = validateAddFrom();
        if(postData.validated){
            delete postData.validated;
            $.ajax({
                type: "POST",
                url: "${contextPath}/metaGenAttr/add",
                dataType:"json",
                contentType:"application/json",
                async: false,
                data:JSON.stringify(postData),
                success: function(data){
                  if("success" == data.status){
                    $('body').tipCenter('clear');
                    $('body').tipCenter('success',data.message);
                    $('#'+reftableid).bootstrapTable('refresh'); 
                    $parentContainer.modal('hide');  
                  }else if("failure" == data.status){

                    if(data.validateMessages){
                      $('body').tipCenter('warning',data.validateMessages);
                    }else{
                      $('body').tipCenter('error',data.message);
                    }
                      
                  }
                    
                }
            });
        }
    });

    
    
    
  });
</script>
  